<template>
	<!-- 隐患下达 -->
	<view class="">
		<u-navbar title="隐患整改" :placeholder="true" leftIconColor="#fff" @rightClick="openPopup" titleStyle="color: #fff" bgColor="#2172FC" :autoBack="true">
			<template #right>
				<u-icon name="hourglass" color="#fff" size="25"></u-icon>
			</template>
		</u-navbar>
	</view>
	<view class="p-10">
		<u-sticky class="p-10" style="background-color: #fff">
			<u-subsection :list="tabList" activeColor="#2172FC" :current="currentKey" mode="subsection" @change="handleTabClick"></u-subsection>
		</u-sticky>
		<template v-if="list.length > 0">
			<view class="card" v-for="(item, index) in list" @click="goDetail(item)">
				<view class="flex m-between">
					<view class="name fw">
						{{ item.dataTypeName }}
					</view>
					<view class="grade fw">隐患状态: {{ item.remark }}</view>
				</view>
				<view class="flex m-between m-t-8">
					<view class="post">隐患等级: {{ item.hiddenLevelName }}</view>
					<view class="pro">检查日期: {{ item.checkDate }}</view>
				</view>
				<view class="flex m-between m-t-8">
					检查人:
					<up-text :lines="1" :text="item.inspectUserNames"></up-text>
				</view>
				<view class="flex m-between m-t-8">检查地点: {{ item.riskLocationName }}</view>
			</view>
		</template>
		<u-empty v-else mode="data"></u-empty>
	</view>
	<!-- 筛选popup -->
	<my-popup :show="showPopup" :queryParams="queryParams" :formItem="formData" @close="closePopup" @reset="reset" @submit="submit"></my-popup>
	<u-back-top :scroll-top="scrollTop" top="600"></u-back-top>
</template>
<script setup>
import { onShow } from '@dcloudio/uni-app';
import { reactive, ref } from 'vue';
import { unMinPageFindHiddenDanger } from '@/api/hidden-danger.js';
import Dict from '@/store/dict.js';
import useList from '@/hooks/useList.js';

const dict = Dict();
let currentKey = ref(0),
	queryParams = reactive({
		needCount: 1,
		pageNum: 1,
		pageSize: 10,
		state: 2,
		startTime: '',
		endTime: ''
	}),
	tabList = [
		{
			name: '待整改隐患'
		},
		{
			name: '已整改隐患'
		}
	];
const handleTabClick = (index) => {
	currentKey.value = index;
	if (index == 1) {
		// queryParams.stateList = [2, 3]
		queryParams.state = 3;
	} else {
		// queryParams.stateList = []
		queryParams.state = 2;
	}
	queryParams.pageNum = 1;
	getListData();
};
// 跳转详情
const goDetail = (item) => {
	uni.navigateTo({
		url: '/pages/professional/hiddenTrouble/rectify/detail?data=' + JSON.stringify(item)
	});
};
// 字典数据
const getDicts = () => {
	dict.GETspecialtyKey();
};
const { getListData, getCheckPonit, list, scrollTop, formData, showPopup, openPopup, closePopup, reset, submit } = useList({
	queryParams,
	api: {
		page: unMinPageFindHiddenDanger
	}
});
// 初始化数据
const init = () => {
	getListData();
	getDicts();
	getCheckPonit();
};
onShow(() => {
	init();
});
</script>
<style lang="scss" scoped></style>
